
<%@page import="java.sql.ResultSet"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="br.com.integrator.util.ConnectionFactory"%>
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="CSS/style.css" rel="stylesheet" type="text/css" />
        <title>Lista de Dvds</title>
    </head>
    <body style="background-color:#E2E4E4">
        <div class="header">
            <img src="Imagens/logo_musica.jpg" alt="musica" />
            
        </div>
        <ul id="menu-principal">
             <li><a href="index.jsp">Principal</a></li>
            <li><a href="mostrarDvdCads_2.jsp">Dvd</a></li>
            <li><a href="mostrarCdCads_2.jsp">Cd</a></li>            
            <li><a href="#">Contato</a></li>
            <li><a href="#">Restrito</a></li>
            <li><a href="FormInserindoDadosDvd.jsp">Cad.Dvd</a></li>
            <li><a href="FormInserindoDadosCd.jsp">Cad.Cd</a></li>
        </ul>
        <div class="conteudo">   
            <h1>Lista de Dvds</h1>
      <table border='1'>
       <tr>
                <th>ID</th>
                <th>Nome</th>
                <th>Autor</th>
                <th>Gravadora</th>
                <th>Edição</th>                
                
            </tr>
        <%
       Connection con = null;
       Statement stmt = null;
       ResultSet rs = null;
       try{
           con=ConnectionFactory.getConnection();
        stmt = con.createStatement();
        rs = stmt.executeQuery("Select * from dvds order by id asc");
        while(rs.next()){
            String id = rs.getString("ID");
            out.println("<tr>");
            out.println("<td>"+id+"</td>");
            //out.println("<td>"+id+"</td>");
            out.println("<td>"+rs.getString("NOME")+"</td>");
            out.println("<td>"+rs.getString("AUTOR")+"</td>");
            out.println("<td>"+rs.getString("GRAVADORA")+"</td>");
            out.println("<td>"+rs.getDate("EDICAO")+"</td>");           
            out.println("</tr>");
        }
            }catch(Exception ex){
             out.println("<tr><td colspan='3'>ERRO: "+ex.getMessage()+"</tr>");
           }finally{
                 try{rs.close();}catch (Exception e){}
                 try{stmt.close();}catch (Exception e){}
                 try{con.close();}catch (Exception e){}
           }
  %>
    </table>
          </div>
        <div class="footer">
              <p>Desenvolvido Rosimeire Salzo</p>
        </div>
        
    </body>
</html>
